import java.util.ArrayList;
import java.util.List;

class Car {
    private String carId;
    // 其他属性...

    public Car(String carId) {
        this.carId = carId;
    }

    public String getCarId() {
        return carId;
    }

    // 其他getter和setter...
}

class Sale {
    private String saleId;
    private String carId;
    private String buyerId;

    public Sale(String saleId, String carId, String buyerId) {
        this.saleId = saleId;
        this.carId = carId;
        this.buyerId = buyerId;
    }

    public String getSaleId() {
        return saleId;
    }

    public String getCarId() {
        return carId;
    }

    public String getBuyerId() {
        return buyerId;
    }

    public void setSaleId(String saleId) {
        this.saleId = saleId;
    }

    public void setCarId(String carId) {
        this.carId = carId;
    }

    public void setBuyerId(String buyerId) {
        this.buyerId = buyerId;
    }
    // getter和setter方法...
}

class CarDealer {
    private List<Car> cars = new ArrayList<>();
    private List<Sale> sales = new ArrayList<>();

    // 添加汽车到库存
    public void addCar(Car car) {
        cars.add(car);
    }

    // 销售汽车
    public boolean sellCar(Sale sale) {
        // 检查汽车是否存在
        for (Car car : cars) {
            if (car.getCarId().equals(sale.getCarId())) {
                // 假设销售成功，从库存中移除汽车（这里只是标记为已售）
                cars.remove(car);
                sales.add(sale);
                System.out.println("汽车 " + sale.getCarId() + " 已售出给 " + sale.getBuyerId());
                return true;
            }
        }
        System.out.println("汽车 " + sale.getCarId() + " 不存在，无法销售。");
        return false;
    }

    // 其他方法，如显示库存、销售记录等...
}

public class CarDealerApp {
    public static void main(String[] args) {
        CarDealer dealer = new CarDealer();
        dealer.addCar(new Car("C123"));
        dealer.addCar(new Car("C456"));

        Sale sale = new Sale("S789", "C123", "B101");
        dealer.sellCar(sale);

        // 假设还有其他逻辑...
    }
}